
import Vue from 'vue'
import http from '@/utils/http'

/**
 *
 * 同功能，在不同环境时请求接口路径不同时，分两个对象存储路径
 */

const url = {
	VUE_APP_BASE_API: {
		userInfo: '/sys/user/info',
		userSetPassword: '/sys/user/setPassword',
	},
	VUE_APP_SHOP_API: {
		userInfo: '/merchant/info/detail',
		userSetPassword: '/merchant/info/setPassword',

	}
};

/**
 * 第三个参数，需要post请求，formData传参方式时，传入该字符串。
 */

/**
 * 首页
 */

// 系统用户相关数据统计
export function userList(data) {
  return http.get('/api/sys/users/list', data, 'formData')
}
export function userAdd(data) {
  return http.post('/api/sys/users/info', data, 'formData')
}
export function userUpdate(data) {
  return http.put('/api/sys/users/info', data)
}
export function userDelete(data) {
  return http.delete('/api/sys/users/info?userId='+data, 'formData')
}
export function userInfo(data) {
  return http.get('/api/sys/users/info', data, 'formData')
}
export function userState(data) {
  return http.put('/api/sys/users/state', data)
}
export function userInfoAndRoles(data) {
  return http.get('/api/sys/users/info/roles', data, 'formData')
}
//角色相关
export function roleInfo(data) {
  return http.get('/api/sys/roles/info', data, 'formData')
}
export function roleAdd(data) {
  return http.post('/api/sys/roles/info', data, 'formData')
}
export function roleUpdate(data) {
  return http.put('/api/sys/roles/info', data)
}
export function roleDelete(data) {
  return http.delete('/api/sys/roles/info?roleId='+ data, 'formData')
}
export function roleList(data) {
  return http.get('/api/sys/roles/list', data, 'formData')
}
export function roleUpdateDetail(data) {
  return http.put('/api/sys/roles/info/detail', data)
}
//获取权限列表
export function moduleList(data) {
  return http.get('/api/sys/modules/list', data, 'formData')
}
//系统公共标签设置
export function labelListByParent(data) {
  return http.get('/api/sys/labels/list', data, 'formData')
}
export function labelListByBusinessType(data) {
  return http.get('/api/sys/labels/labelBusinessType', data, 'formData')
}
export function labelListAll(data) {
  return http.get('/api/sys/labels/listAll', data, 'formData')
}
export function setLabelState(data) {
  return http.put('/api/sys/labels/info/status', data)
}
export function changeSort(data) {
  return http.put('/api/sys/labels/info/sort', data)
}
export function labelAdd(data) {
  return http.post('/api/sys/labels/info', data, 'formData')
}
export function labelUpdateText(data) {
  return http.put('/api/sys/labels/info/labelText', data)
}
export function labelDelete(data) {
  return http.delete('/api/sys/labels/info?labelId='+data, 'formData')
}
//音乐管理设置
export function musicAdd(data) {
  return http.post('/api/sys/musics/info', data, 'formData')
}
export function musicList(data) {
  return http.get('/api/sys/musics/list', data, 'formData')
}
export function musicUpdate(data) {
  return http.put('/api/sys/musics/info', data)
}
export function musicDelete(data) {
  return http.delete('/api/sys/musics/info?musicId='+data, 'formData')
}
//系统通知管理
export function noticeAdd(data) {
  return http.post('/api/sys/notices', data, 'formData')
}
export function noticeList(data) {
  return http.get('/api/sys/notices/list', data, 'formData')
}
export function noticeInfo(data) {
  return http.get('/api/sys/notices', data, 'formData')
}
export function noticeUpdate(data) {
  return http.put('/api/sys/notices', data)
}
export function noticeState(data) {
  return http.put('/api/sys/notices/state', data)
}

/**
 * 
 * banner API
 * 
 */

// banner列表
export function bannerList (data) {
  return http.get('/api/sys/banner/list', data, 'formData')
}

// 新增banner
export function addBanner(data) {
  return http.post('/api/sys/banner/info', data, 'formData', {'Content-Type': 'application/json'})
}

// 编辑banner
export function editBanner(data) {
  return http.put('/api/sys/banner/info', data, {'Content-Type': 'application/json'})
}

// 删除banner
export function deleteBanner(data) {
  return http.post('/api/sys/banner/delete', data, 'formData')
}

// 更新banner状态
export function updateBannerState(data) {
  return http.post('/api/sys/banner/info/status', data, 'formData')
}

//资源文件管理
export function blessingList(data) {
  return http.get('/api/blessing/resources/list', data, 'formData')
}
export function blessingAdd(data) {
  return http.post('/api/blessing/resources/info', data, 'formData')
}
export function blessingUpdate(data) {
  return http.put('/api/blessing/resources/info', data)
}
export function blessingState(data) {
  return http.put('/api/blessing/resources/info/state', data)
}
export function blessingRemarkType(data) {
  return http.put('/api/blessing/resources/info/remarkType', data)
}
export function blessingSort(data) {
  return http.put('/api/blessing/resources/sort', data)
}

export function blessingLabels(data) {
  return http.put('/api/blessing/resources/info/labels', data)
}
export function blessingDelete(data) {
  return http.delete('/api/blessing/resources/info/delete?resourceUid='+ data, 'formData')
}
export function sendRecords(data) {
  return http.get('/api/blessing/resources/sendRecords', data, 'formData')
}
export function sendRecordCounts(data) {

  return http.get('/api/blessing/resources/sendRecordCounts', data, 'formData')
}

//用户档案管理中心
export function memberList(data) {
  return http.get('/api/member/members/list', data, 'formData')
}
export function memberRemark(data) {
  return http.put('/api/member/members/info/remarks', data)
}
export function memberType(data) {
  return http.put('/api/member/members/info/type', data)
}
export function memberLabel(data) {
  return http.put('/api/member/members/info/label', data)
}

//活动基础信息控制类
export function campaignsList(data) {
  return http.get('/api/campaigns/list', data, 'formData')
}
export function campaignsAdd(data) {
  return http.post('/api/campaigns/info', data, 'formData')
}
export function campaignsUpdate(data) {
  return http.put('/api/campaigns/info', data)
}
export function campaignsDelete(data) {
  return http.post('/api/campaigns/info/delete',data, 'formData')
}
export function campaignsState(data) {
  return http.put('/api/campaigns/info/state', data)
}
export function campaignsOnline(data) {
  return http.post('/api/campaigns/info/online', data, 'formData')
}
export function campaignsRules(data) {
  return http.post('/api/campaigns/info/rules', data, 'formData')
}
export function getTemplateList(data) {
  return http.get('/api/campaignTemplate/list', data, 'formData')
}
// 添加活动模板
export function templateAdd(data) {
  return http.post('/api/campaignTemplate/info', data, 'formData', {'Content-Type': 'application/json'})
}
// 编辑活动模板
export function templateEdit(data) {
  return http.put('/api/campaignTemplate/info', data, {'Content-Type': 'application/json'})
}
// 删除活动模板
export function templateDelete(data) {
  return http.post('/api/campaignTemplate/info/delete', data, 'formData')
}

//查询活动规则
export function campaignsRulesList(data) {
  return http.get('/api/campaigns/info/rules/list', data, 'formData')
}
export function campaignsSetRules(data) {
  return http.post('/api/campaigns/info/setRules', data, 'formData')
}
//活动物资相关
//追加物资明细
export function campaignsMaterialAdd(data) {
  return http.post('/api/campaigns/material/detail', data, 'formData')
}
//创建活动物资
export function campaignsMaterialCreate(data) {
  return http.post('/api/campaigns/material/info', data, 'formData')
}
//修改活动物资
export function campaignsMaterialUpdate(data) {
  return http.put('/api/campaigns/material/info', data)
}
//查询活动物资操作明细
export function campaignsMaterialDetailList(data) {
  return http.get('/api/campaigns/material/info/detail/list', data, 'formData')
}
//删除活动物资
export function campaignsMaterialDelete(data) {
  return http.post('/api/campaigns/material/info/delete',data,'formData')
}
//查询活动物资列表
export function campaignsMaterialList(data) {
  return http.get('/api/campaigns/material/info/list', data, 'formData')
}


//活动红包相关
//创建活动红包
export function campaignsRedPacketAdd(data) {
  return http.post('/api/campaigns/redPacket/info', data, 'formData')
}
//查看活动红包投放记录
export function campaignsRedPacketList(data) {
  return http.get('/api/campaigns/redPacket/list', data, 'formData')
}
//查看某用户红包领取记录
export function campaignsRedPacketMemberDetail(data) {
  return http.get('/api/campaigns/redPacket/member/detail', data, 'formData')
}
//查询某用户红包领取汇总信息
export function campaignsRedPacketMemberTotal(data) {
  return http.get('/api/campaigns/redPacket/member/total', data, 'formData')
}
//活动物资领取记录列表
//活动物资确认
export function campaignsMaterialConfirm(data) {
  return http.post('/api/campaigns/material/manager/info/confirm', data, 'formData')
}
//兑换订单物流查询
export function campaignsMaterialDelivery(data) {
  return http.get('/api/campaigns/material/manager/info/delivery', data, 'formData')
}
//查询活动物资列表
export function campaignsMaterialInfoList(data) {
  return http.get('/api/campaigns/material/manager/info/list', data, 'formData')
}
//活动物资兑换订单发货
export function campaignsMaterialSend(data) {
  return http.post('/api/campaigns/material/manager/info/send', data, 'formData')
}
//获取物流公司列表
export function trackingCompanyList(data) {
  return http.get('/api/delivery/channel/list', data, 'formData')
}
//活动查询用户发送祝福列表
export function sendBlessingRecordList(data) {
  return http.get('/api/campaigns/blessing/sendRecord', data, 'formData')
}
//用户积分查询
export function userPointList(data) {
  return http.get('/api/campaigns/points/list', data, 'formData')
}
//获取用户领取物资记录
export function userGetMaterialList(data) {
  return http.get('/api/campaigns/points/materials/detail', data, 'formData')
}
//红包领取记录查询
export function userPacketRecordList(data) {
  return http.get('/api/campaigns/packet/record', data, 'formData')
}

/**
 * 系统配置
 */
//获取系统配置列表
export function systemConfigList(data) {
  return http.get('/api/sys/setting/list', data, 'formData')
}
//修改系统配置参数
export function systemConfigUpdate(data) {
  return http.post('/api/sys/setting/update', data, 'formData')
}

/**
 * 用户反馈信息
 */
export function opinionsList(data) {
  return http.get('/api/sys/opinions/list', data, 'formData')
}
//阅读反馈信息
export function opinionsIsRead(data) {
  return http.put('/api/sys/opinions/isRead', data)
}

/**
 * 定时任务管理
 */
//开启活动订单定时检查任务
export function startCampaignOrderSchedule(data) {
    return http.post('/api/scheduled/campaigns/job/start', data, 'formData')
}
//关闭活动订单定时检查任务
export function stopCampaignOrderSchedule(data) {
    return http.post('/api/scheduled/campaigns/job/stop', data, 'formData')
}
//开启资源定时发布任务
export function startResourceReleaseSchedule(data) {
    return http.post('/api/scheduled/release/job/start', data, 'formData')
}
//关闭资源定时发布任务
export function stopResourceReleaseSchedule(data) {
    return http.post('/api/scheduled/release/job/stop', data, 'formData')
}

//开启活动定时发布任务
export function startCampaignsReleaseSchedule(data) {
    return http.post('/api/scheduled/campaigns/state/start', data, 'formData')
}
//关闭活动定时发布任务
export function stopCampaignsReleaseSchedule(data) {
    return http.post('/api/scheduled/campaigns/state/stop', data, 'formData')
}


// 获取七牛云token
export function getQiniuToken() {
	return http.get('/medias/image/qiniu/token')
}

/**
 * 
 * 商城api
 * 
 */

// 商品列表
export function getGoodslist(data) {
  return http.get('/api/goods/list', data, 'formData')
}

// 添加商品
export function addGoods(data) {
  return http.post('/api/goods/info', data, 'formData', {'Content-Type': 'application/json'})
}

// 编辑商品
export function editGoods(data) {
  return http.put('/api/goods/info', data, {'Content-Type': 'application/json'})
}

// 删除商品
export function deleteGoods(data) {
  return http.post('/api/goods/info/delete', data, 'formData')
}

// 修改商品状态
export function updateGoodsState(data) {
  return http.put('/api/goods/info/state', data)
}

// 获取商品分类
export function categoryList(data) {
  return http.get('/api/goods/categoryList', data, 'formData')
}

// 获取商户列表
export function merchantList(data) {
  return http.get('/api/goods/merchantList', data, 'formData')
}

// 订单列表
export function ordersList(data) {
  return http.get('/api/orders/list', data, 'formData')
}

// 订单详情
export function ordersDetail(data) {
  return http.get('/api/orders/info', data, 'formData')
}

// 更改订单状态
export function updateOrdersStatus(data) {
  return http.post('/api/orders/info/status', data, 'formData')
}

// 发货(可批量)
export function ordersDeliver(data) {
  return http.post('/api/orders/deliver', data, 'formData')
}

// 查看物流
export function ordersMaterialFlow(data) {
  return http.get('/api/orders/materialFlow', data, 'formData')
}

// 红包列表
export function redPacket(data) {
  return http.get('/api/redPacket/list', data, 'formData')
}

// 编辑红包
export function editRedPacket(data) {
  return http.put('/api/redPacket/info', data, {'Content-Type': 'application/json'})
}

// 删除红包
export function deletePacket(data) {
  return http.post('/api/redPacket/info/delete', data, 'formData')
}

// 新增红包
export function addRedPacket(data) {
  return http.post('/api/redPacket/info', data, 'formData', {'Content-Type': 'application/json'})
}


/**
 * 
 * 勋章api
 * 
 */

// 勋章列表
export function medalList(data) {
  return http.get('/api/medals/list', data, 'formData')
}

// 新增勋章
export function addMedal(data) {
  return http.post('/api/medals/info', data, 'formData', {'Content-Type': 'application/json'})
}

// 编辑勋章
export function editMedal(data) {
  return http.put('/api/medals/info', data, {'Content-Type': 'application/json'})
}

// 删除勋章
export function deleteMedal(data) {
  return http.post('/api/medals/info/delete', data, 'formData')
}

// 更新勋章状态
export function updateMedalState(data) {
  return http.post('/api/medals/status', data, 'formData')
}

// 设置勋章的状态
export function setEquity(data) {
  return http.post('/api/medals/setEquity', data, 'formData')
}

// 权益列表
export function rightsList (data) {
  return http.get('/api/medal/rights/list', data, 'formData')
}

// 新增权益
export function addRights(data) {
  return http.post('/api/medal/rights/info', data, 'formData', {'Content-Type': 'application/json'})
}

// 编辑权益
export function editRights(data) {
  return http.put('/api/medal/rights/info', data, {'Content-Type': 'application/json'})
}

// 删除权益
export function deleteRights(data) {
  return http.post('/api/medal/rights/delete', data, 'formData')
}

// 勋章领取记录
export function medalRecordList (data) {
  return http.get('/api/medal/record/list', data, 'formData')
}

// 查看用户获得权益记录列表
export function getRightRecord (data) {
  return http.get('/api/medal/getRightRecord/list', data, 'formData')
}
